﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class emailus : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mailTo = "fantongshun108@126.com";
        
        string subject = "客户留言的主题："+ListBox1.SelectedItem.Text;
        string password = "85850678ftsh++";
        string content = GetUserInfo();
        MyNamespace.SendMail send = new MyNamespace.SendMail(mailTo, mailTo, content, subject, password);
        
        if (send.Send())
        {
            Response.Write(" <script   language=JavaScript> var   retValue=window.confirm( '发送成功'); </script> ");
        }
        else
        {
            Response.Write(" <script   language=JavaScript> var   retValue=window.confirm( '发送失败'); </script> ");

        }
        clearWebCtr();

        //关闭当前页面
        //ClientScript.RegisterStartupScript(Page.GetType(), "", "<script language=javascript>window.opener=null;window.open('','_self');window.close();</script>");
        //返回之前页面
        this.Server.Transfer("~/page_57.htm");
    }

    private string GetUserInfo()
    {
        string info="";
        info = "这是来自客户的邮件,客户信息入下：\r\n";
        info += "电子邮件： " + TextBox1.Text + "\r\n";
        info += "名字： " + TextBox2.Text + "\r\n";
        info += "公司名称： " + TextBox3.Text + "\r\n";
        info += "地址： " + TextBox4.Text + "\r\n";
        info += "国家： " + TextBox5.Text + "\r\n";
        info += "电话： " + TextBox6.Text + "\r\n";
        info += "主题： " + ListBox1.SelectedItem.Text + "\r\n";
        info += "评论： " + TextBox7.Text + "\r\n";
        return info;
    }

    private void clearWebCtr()
    {
        TextBox1.Text = null;
        TextBox2.Text = null;
        TextBox3.Text = null;
        TextBox4.Text = null;
        TextBox5.Text = null;
        TextBox6.Text = null;
        TextBox7.Text = null;
    }
}
